﻿package mortal.game.view.ThanksGiving.panel
{
    import com.gengine.core.frame.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.ThanksGiving.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.copy.GroupTowerCopy.data.*;
    import mortal.game.view.rebate.item.*;
    import mortal.game.view.shopMall.shopSecKilling.*;

    public class ThanksGivingShopPanel extends GSprite
    {
        protected var _mbg:GImageBitmap;
        protected var _desTxt:GTextFiled;
        protected var _timeDetail:GTextFiled;
        protected var _list:CellsGridSprite;
        protected var _addBtn:GLoadingButton;
        protected var _reNumDes:GTextFiled;
        protected var _reNum:GTextFiled;
        protected var _day:BitmapNumberText;
        protected var _hour:BitmapNumberText;
        protected var _min:BitmapNumberText;
        protected var _sec:BitmapNumberText;
        protected var _reBtn:GLoadingButton;
        protected var _yuanbo:GBitmap;
        private var _secT:SecTimer;

        public function ThanksGivingShopPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._mbg = UIFactory.gImageBitmap(ImagesConst.ThanksGivingShopBg, 0, 0, this);
            this._desTxt = UIFactory.gTextField("TextField", 51, 224, 600, 80, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._timeDetail = UIFactory.gTextField("", 46, 348, 620, 25, this, GlobalStyle.textFormatLv);
            this._list = UIFactory.getUICompoment(CellsGridSprite);
            this._list.colNum = 8;
            this._list.vCellWid = 45;
            this._list.hCellWid = 100;
            this._list.genCellFun = this.genItem;
            this._list.genCells(8);
            this._list.x = 53;
            this._list.y = 424;
            this.addChild(this._list);
            this._addBtn = UIFactory.gLoadingButton(ImagesConst.CombinedSerAddAct_upSkin, 274, 491, 141, 42, this);
            this._addBtn.label = "";
            this._reNumDes = UIFactory.gTextField("", 350, 145, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._reNum = UIFactory.gTextField("12346", 417, 145, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._day = UIFactory.bitmapNumberText(153, 105, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._day.text = "00";
            this._hour = UIFactory.bitmapNumberText(208, 105, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hour.text = "00";
            this._min = UIFactory.bitmapNumberText(279, 105, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._min.text = "00";
            this._sec = UIFactory.bitmapNumberText(350, 105, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._sec.text = "00";
            this._reBtn = UIFactory.gLoadingButton(ImagesConst.investmentRechargeBtn_upSkin, 544, 129, 141, 43, this);
            this._reBtn.label = "";
            this._yuanbo = UIFactory.gBitmap(ImagesConst.Yuanbao, 514, 146, this);
            this._secT = new SecTimer(1);
            this._secT.addListener(TimerType.ENTERFRAME, this.timeCk);
            this._secT.start();
            this.timeCk(null);
            this._addBtn.configEventListener(MouseEvent.CLICK, this.onGoto);
            this.updateRuleAndTime();
            this.updateTreasureNum();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._secT.stop();
            this._secT.dispose(param1);
            this._secT = null;
            this._mbg = null;
            this._desTxt = null;
            this._timeDetail = null;
            this._list = null;
            this._addBtn = null;
            this._reNumDes = null;
            this._reNum = null;
            this._day = null;
            this._hour = null;
            this._min = null;
            this._sec = null;
            this._reBtn = null;
            this._yuanbo = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function genItem() : RebateItem2
        {
            var _loc_1:* = UIFactory.getUICompoment(RebateItem2);
            return _loc_1;
        }// end function

        private function timeCk(param1:SecTimer) : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            _loc_2 = ThanksGivingUtil.getDayCountDownTime();
            _loc_3 = _loc_2[5];
            this._day.text = "" + _loc_2[0];
            this._hour.text = "" + _loc_2[1];
            this._min.text = "" + _loc_2[2];
            this._sec.text = "" + _loc_2[3];
            if (_loc_3 > 0)
            {
                if (this._secT.running == false)
                {
                    this._secT.start();
                }
            }
            else
            {
                this._secT.stop();
            }
            return;
        }// end function

        private function updateRuleAndTime() : void
        {
            if (Cache.instance.thanksGiving != null && Cache.instance.thanksGiving.consumInfo != null)
            {
                this._reNum.text = "" + Cache.instance.thanksGiving.consumInfo.recharge;
            }
            else
            {
                this._reNum.text = "0";
            }
            this._reNumDes.text = "" + Language.getString(71406);
            this._timeDetail.text = ThanksGivingUtil.getOpenTimeStr(71375);
            var _loc_1:* = GlobalStyle.textFormatChen.setSize(13);
            _loc_1.leading = 5;
            this._desTxt.defaultTextFormat = _loc_1;
            this._desTxt.htmlText = Language.getString(71409);
            var _loc_2:* = ThanksGivingUtil.shopGiftCode;
            RewardCfgUtil.updateRwListByGiftCode(_loc_2, this._list);
            return;
        }// end function

        private function onGoto(event:MouseEvent) : void
        {
            ShopSecKillingWin.instance.show();
            return;
        }// end function

        public function updateTreasureNum() : void
        {
            return;
        }// end function

    }
}
